/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-05-09
 * Time: 18:28
 */

//使用接口
class Animal1{
    protected String name;

    public Animal1(String name){
        this.name = name;
    }
}
// 不是所有动物都会飞 且一个类不能继承多个类 写成接口
interface IFlying{
    void fly();
}
interface IRunning{
    void run();
}

interface ISwimming{
    void wing();
}


class Dog1 extends Animal1 implements IRunning{
    public Dog1(String name){
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name+" 正在跑！");
    }
}//狗会跑 但是不能把跑写在Animal1里面

class Bird1 extends Animal1 implements IFlying{
    public Bird1(String name){
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(this.name + "正在飞");
    }
}//鸟会飞 但是不能把跑写在Animal1里面

class Frog extends Animal1 implements IRunning,ISwimming{
    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }

    public Frog(String name) {
        super(name);
    }

    @Override
    public void wing() {
        System.out.println(this.name+"正在游泳！");
    }
}


public class Test5 {

    public static void run(IRunning iRunning){
        iRunning.run();
    }

    public static void swing(ISwimming iSwimming){
        iSwimming.wing();
    }

    public static void main(String[] args) {
        run(new Dog1("狗"));
        swing(new Frog("🐸"));
    }
}
